unit gare_frm;

{$mode objfpc}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  DbCtrls, StdCtrls, datamodule1_frm;

type

  { TGare }

  TGare = class(TForm)
    btchiudi: TButton;
    btsalva: TButton;
    cbtipo: TDBComboBox;
    edprev_avvio: TDBEdit;
    edeff_avvio: TDBEdit;
    edesple: TDBEdit;
    edpre_agg: TDBEdit;
    edpre_per: TDBEdit;
    edipmbaseasta: TDBEdit;
    edimpre_agg: TDBEdit;
    edimpresa: TDBEdit;
    edrib_cons: TDBEdit;
    Label1: TLabel;
    Label10: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    procedure btchiudiClick(Sender: TObject);
    procedure btsalvaClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
  private
    { private declarations }
  public
    { public declarations }
    nuovoidgara:integer;
  end; 

var
  Gare: TGare;

implementation

{ TGare }

procedure TGare.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
  CloseAction:=caFree;
end;

procedure TGare.btchiudiClick(Sender: TObject);
begin
  close;
end;

procedure TGare.btsalvaClick(Sender: TObject);
begin
  if btsalva.Caption = 'Salva' then
     begin
       //asdasd
       datamodule1.zqgare.FieldByName('IDOPERA').Value:=DataModule1.dsaffidreal.DataSet.FieldByName('AN_OP_ID_OPERA').AsInteger;
       datamodule1.zqgare.FieldByName('IDPRELIMINARE').Value:=DataModule1.dsaffidreal.DataSet.FieldByName('IDPRELIMINARE').AsInteger;
       datamodule1.zqgare.FieldByName('IDDEFINITIVO').Value:=DataModule1.dsaffidreal.DataSet.FieldByName('IDDEFINITIVO').AsInteger;
       datamodule1.zqgare.FieldByName('IDESECUTIVO').Value:=DataModule1.dsaffidreal.DataSet.FieldByName('IDESECUTIVO').AsInteger;
       datamodule1.zqgare.FieldByName('IDGARA').Value:=nuovoidgara;
     end;
  DataModule1.zqgare.ApplyUpdates;
  DataModule1.zqgare.CommitUpdates;
    //aggiorna la griglia del preliminari
  DataModule1.dsgare.DataSet.Refresh;
  Close;
end;


initialization
  {$I gare_frm.lrs}

end.

